package cn.hnbjx.prepaid.dao;

import cn.hnbjx.prepaid.pojo.NumData;
import cn.hnbjx.prepaid.pojo.RescueUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RescueUserDao {

    @Select("select * from `rescue_user`  order by id desc")
    List<RescueUser> findAll(String key);
    @Select("select * from `rescue_user` where `rescueUserId`=#{id} and `flag`=#{type}  order by id desc")
    List<RescueUser> apifindAll(@Param("type") Integer type,@Param("id") Integer id);
    @Select("select * from `rescue_user` where `userHelpId`=#{help_id} order by id desc")
    RescueUser findByHelpId(Integer help_id);

    @Insert("insert into rescue_user (rescueUserId,userId,userHelpId,flag,createTime,city) values (#{rescueUserId},#{userId},#{userHelpId},#{flag},now(),#{city})")
    void insert(RescueUser rescueUser);

    @Select("select city,count(*) as num from rescue_user  group by city")
    List<NumData> findByNum();
}
